package com.mc.jf.controller;


import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import com.mc.jf.entity.Plan;
import com.mc.jf.service.impl.PlanServiceImpl;
import com.mc.jf.utils.DateUtils;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Controller
@RequestMapping("tools")
public class ToolsController {

    @Autowired
    PlanServiceImpl planService;


    @RequestMapping("date")
    @ResponseBody
    public String getdate(){

        List<String> dateList=DateUtils.getAllDateOfYear();
        List<Plan> plans=new ArrayList<>();
        for (String date:dateList) {
//            plans.add(getPlan("1","付焕思", date));
//            plans.add(getPlan("2","苏堪斌", date));
//            plans.add(getPlan("3","朱继涛", date));
        }
        planService.saveBatch(plans);
        return "success";
    }


    private Plan getPlan(String uid,String name, String date) {
        Plan plan=new Plan();
        plan.setUid(uid);
        plan.setLocation("");
        plan.setAction("");
        plan.setUsername(name);
        plan.setDate(date);
        return plan;
    }


}
